local skel = fk.CreateSkill {
  name = "rmt__mingzhao",
  tags = {Skill.Hidden},
}

Fk:loadTranslationTable{
  ["rmt__mingzhao"] = "冥诏",
  [":rmt__mingzhao"] = "隐匿，你登场或死亡时，你可以令除当前回合角色外的其他角色各弃置一张牌。",
  ["#rmt__mingzhao-invoke"] = "你可以令除 %src 外的其他角色各弃置一张牌",

  ["rmt__zhijing"] = "职竞",
  [":rmt__zhijing"] = "锁定技，当你使用牌时，若本轮获得牌数最多的角色为你，此牌伤害基数+1，否则你摸一张牌。",

  ["$rmt__mingzhao1"] = "今辄奉诏诛贾郭，匡正王室，以安天下！",
  ["$rmt__mingzhao2"] = "受诏而行，谓为社稷。",
}

local U = require "packages.utility.utility"

local on_cost = function (self, event, target, player, data)
  local room = player.room
  local targets = room:getOtherPlayers(player)
  table.removeOne(targets, room:getCurrent())
  if #targets > 0 and room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#rmt__mingzhao-invoke:"..room.current.id}) then
    event:setCostData(self, {tos = targets})
    return true
  end
end

local on_use = function (self, event, target, player, data)
  local room = player.room
  for _, p in ipairs(event:getCostData(self).tos) do
    if not p.dead and not p:isNude() then
      room:askToDiscard(p, { min_num = 1, max_num = 1, include_equip = true, skill_name = skel.name, cancelable = false})
    end
  end
end

skel:addEffect(U.GeneralAppeared, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name)
  end,
  on_cost = on_cost,
  on_use = on_use,
})

skel:addEffect(fk.Death, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name, false, true)
  end,
  on_cost = on_cost,
  on_use = on_use,
})

return skel
